<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/static/include/taglib.jsp"%>

<!DOCTYPE html>
<html>
<head>
	<title>商品分类</title>
	<%@ include file="/static/include/head.jsp" %>
</head>
<body>
<!-- 模态框（Modal） -->
<form id="inputForm" modelAttribute="goodsType" action="${ctx}/product/goodsType/save" method="post" class="form-horizontal">
	<!-- <div class="modal-content"> -->
		<div class="modal-header">
			<button class="close" type="button" data-dismiss="modal">×</button>
			<h4 class="modal-title" id="myModalLabel">商品分类维护</h4>
		</div>
		<div class="modal-body">
            <!-- error message here -->
            <div id="messageBox" class="alert alert-warning hide"></div>
			<tags:message content="${message}"/>
            <c:if test="${param.type eq 'edit'}">
				<input type="hidden" id="id" name="id" value="${goodsType.id}" />
			</c:if>
                <!-- form filed -->
				<div class="form-group">
					<label class="col-sm-5 control-label no-padding-right">类型名称:</label>
					<div class="col-xs-6">
						<input type="text" id="name" name="name" value="${goodsType.name}"
							   placeholder="类型名称" class="form-control  required  ">
					</div>
				</div>
                <!-- form filed -->
				<div class="form-group">
					<label class="col-sm-5 control-label no-padding-right">此类型商品是否拥有属性:</label>
					<div class="col-xs-6">
						<input type="radio" id="haveProp" name="haveProp" value="1" <c:if test="${goodsType.haveProp eq 1}">checked</c:if><c:if test="${empty goodsType.haveProp}">checked</c:if>> 是&nbsp;&nbsp; 
						<input type="radio" id="haveProp" name="haveProp" value="0" <c:if test="${goodsType.haveProp eq 0}">checked</c:if>> 否
					</div>
				</div>
                <!-- form filed -->
				<div class="form-group">
					<label class="col-sm-5 control-label no-padding-right">此类型商品是否拥有参数:</label>
					<div class="col-xs-6">
						<input type="radio" id="haveParm" name="haveParm" value="1" <c:if test="${goodsType.haveParm eq 1}">checked</c:if><c:if test="${empty goodsType.haveParm}">checked</c:if>> 是&nbsp;&nbsp; 
						<input type="radio" id="haveParm" name="haveParm" value="0" <c:if test="${goodsType.haveParm eq 0}">checked</c:if>> 否
					</div>
				</div>
                <!-- form filed -->
				<div class="form-group">
					<label class="col-sm-5 control-label no-padding-right">此类型商品是否关联品牌:</label>
					<div class="col-xs-6">
						<input type="radio" id="joinBrand" name="joinBrand" value="1" <c:if test="${goodsType.joinBrand eq 1}">checked</c:if><c:if test="${empty goodsType.joinBrand}">checked</c:if>> 是&nbsp;&nbsp; 
						<input type="radio" id="joinBrand" name="joinBrand" value="0" <c:if test="${goodsType.joinBrand eq 0}">checked</c:if>> 否
					</div>
				</div>
                <!-- form filed -->
				<div class="form-group">
					<label class="col-sm-5 control-label no-padding-right">此类型商品是否关联规格:</label>
					<div class="col-xs-6">
						<input type="radio" id="joinSpec" name="joinSpec" value="1" <c:if test="${goodsType.joinSpec eq 1}">checked</c:if><c:if test="${empty goodsType.haveField}">checked</c:if>> 是&nbsp;&nbsp; 
						<input type="radio" id="joinSpec" name="joinSpec" value="0" <c:if test="${goodsType.joinSpec eq 0}">checked</c:if>> 否
					</div>
				</div>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <c:if test="${param.type ne 'view'}">
			<button type="submit" class="btn btn-primary" onclick="doSubmit()">提交更改</button>
			</c:if>
		</div>
	<!-- </div> -->
</form>
<script>
	function doSubmit() {
        $("#inputForm").validate({
            submitHandler: function(form){
                form.submit();
            },
            errorContainer: "#messageBox",
            errorPlacement: function(error, element) {
                $("#messageBox").html('<div class="alert alert-danger">' +
					'<a href="#" class="close" data-dismiss="alert">&times;</a>' +
					'<strong>警告！</strong>输入有误，请进行一些更改。</div>');
                if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                    error.appendTo(element.parent().parent());
                } else {
                    error.insertAfter(element);
                }
            }
        });
    }
</script>
</body>
</html>
